Create PDF Copies of Completed Forms
Digitise Forms includes the ability to create and display a PDF copy of a completed form.
A PDF copy can be created automatically or on demand and can either be saved to a specified folder or to a SQL database (see the Save PDFs to a SQL database drop-down, below, for more information), from where it can be displayed in the user's browser, allowing the user to save or print the PDF copy, if required.
- You can create a PDF copy of a form where elements on the form are mapped to different Datasources, provided the Store Request Data option is selected for each Datasource within the form's Publishing Profile. Also, the Is Visible in PDF option needs to be selected for elements which you wish to include within the PDF (see the Map Data to Elements topic for more details). If either the Store Request Data or Is Visible in PDF options are deselected, the elements will not be visible within the PDF.
The PDF copy can be created automatically when a user submits the form. This would normally be done through a Submit Button on your form or by calling the submitForm function within custom JavaScript. If you are using the Capita Pay360 payment service to take payment for goods or services, you can submit the form as part of the payment process. However the form is submitted, when you publish your form you can optionally specify that you want a PDF copy of the form to be created automatically whenever the form is submitted and specify a folder to hold the PDF files. Alternatively, you can configure a connection to a SQL database within which a copy of the PDF will be retained.
To allow the user to create a PDF copy on demand and to download it to their browser, you will need to provide a way for the user to submit the form and include a Get PDF Button Element on the form. You also need to specify a folder or a SQL database to hold the PDF files, which you do when you publish your form.
The Get PDF Button Element checks in your specified PDF files folder or SQL database to see if there is a PDF file created by the current copy of the form and, if there is one, downloads it to the user's browser, from where the user can use the browser's own features to save or print the form, if they want to.
If no PDF file exists, the button creates it from the last form submission, stores it in the PDF files folder or SQL database, and then downloads it to the user's browser. If the form hasn't yet been submitted, an error message will be displayed telling the user that they need to submit the form before they can download the PDF copy.
In order to create PDF copies from a form, you first need to create a template, within Form Studio, which will provide the format of the document, and then configure the Publishing Profile to create PDF files.

Open your project in Form Studio, if not already open.
If you want to record completed forms by producing a PDF copy of the completed form, you will need to provide a means for the form to be submitted. You can create the PDF template before you do this, although we suggest you do it afterwards.
The simplest way to allow users to submit your form is to add a Submit Button Element to it. The user will click or tap this button to submit their form, once completed.
Other ways you can submit the form include using the Submit form action in an Event or using the submitForm scripting function in a custom JavaScript.
If you intend to use the Capita Pay360 payment service to take payment for goods or services, you can submit the form as part of the payment process, rather than use a Submit button. In this case, you will need to add a Capita Pay360 Cart Element to the form and configure the Element to submit the form.
Once you have added a means to submit your form, click on the Project tab in the Project Explorer.
Expand the Forms node in the project tree view.
Right-click on the form name.
Choose Generate Word template.
The Studio will generate a Microsoft Word template including all Elements on your form which have an output mapping and some other Elements such as titles, labels and images. Before you generate the template, make sure you have output-mapped all the Elements on the form whose values you want to include in your PDF file.
When Word generation completes, the template is written to a temporary file and a temporary file dialog box is displayed:
To check the temporary file, click the View Template button. This isn't a prerequisite and you can, if you wish, save or reject the template without examining it first. Note that Digitise Forms will attempt to load the template in MS Word. If you don't have Word, it will attempt to load the template in the default program associated with the .dotx file extension. If you don't have an association configured, a message will be displayed informing you that Form Studio cannot display the template.
Once the temporary file has opened in Word (or in the default, associated program), it can be edited in the usual way. Elements can be added or removed, and changes to the wording of static text items (e.g., element Labels, Label and Paragraph elements, recordset column header Display text etc.) can be applied.
If you view the temporary file and decide not to keep it, close Word. Select the dialog box's Reject Template option, then click OK. The template will be discarded and any existing template will be retained. You can also discard a template by clicking the Cancel button, or by clicking the cross in the dialog box's upper, right-hand corner.
If you view and edit the template and want to keep your changes, save the template in Word then exit the application. Note that you won't need to choose a file name or enter a file location when saving the template in Word. The location and file name are specified when you select the Save Template option. Select Save Template, then click OK. The temporary file will be saved and changes made to it will be retained. Any existing template will be overwritten.
If you view the temporary file and decide not to make changes but still wish to keep it, exit Word. Select the Save Template option, then click OK. The temporary file will be saved using the untouched, auto-generated content and any existing template will be overwritten.
When you select Save Template, a second dialog box showing the save location will appear:
By default, the following information will appear in the Save location box (which shows C:\Users in the above image)
C:\Users\<username>\Documents\NDL Software\Form Studio\Projects\<project
WordTemplates\<form name>.dotx
If you select the Save without editing template option then click Finish, the template will be saved in the above location. If, however, you select Open template for editing then click Finish, the template will still be saved in the above location, but it will open in Word, where you can make and save changes as described above. Click Cancel to abandon the template-saving process, or click the cross in the dialog box's upper, right-hand corner.
As well as being able to generate a Word template by expanding the Forms node in the project tree view and right-clicking on the form name, you can also update the Word template or preview the generated PDF. When you right-click on the form name and select Update Word template, you will be presented with the same dialog box which appears when Generate Word template is selected. When you right-click on the form name and select Preview PDF generation, a PDF will open which contains all of the elements which have been flagged for visibility within the PDF along with accompanying Labels and any static text etc.
You can also preview, edit and generate the PDF using the options provided on the Ribbon's Data tab:
The drop-down above the Preview, Edit and Generate buttons allows you to select the form that you wish to generate a PDF for. When you select Preview, the PDF will open. When you select either Edit or Generate, you will be presented with the same dialog box which appears when Generate Word template is selected.
If you view the temporary file before generating the PDF, it is worth noting that labels are bookmarked to enable updating. The tables in which bookmarks are placed may be restructured if new elements are added, or if their visibility within the PDF is switched on. In these instances, the template may offer a less accurate representation of the eventual PDF. Also, if elements are re-ordered in the form, the updated Word template may not capture the revised order correctly. We therefore recommend previewing the PDF where items have been re-ordered, or where significant changes have been made.
To obtain a preview of your PDF, you will need to have created a Publishing Profile first (see the Publishing Profiles section of the Publish your Form topic). You won't need to publish the project in order to obtain a PDF preview, but the preview requires a Publishing Profile to be present which contains Configuration and Logging database connection strings.
If you have applied HTML/CSS styling to an element using the inline editor, or if an input-mapped database field contains HTML markup, the styling or formatting defined by the markup will be implemented in the PDF. If the markup does not explicitly define the font name, the PDF will use the font defined by the current paragraph. Note that to check any styling applied to an element, you will need to preview the PDF preview. The generated Word template will not display any styling and will show placeholders only for items added to your form. See the Styles and Map Data to Elements topics for more information.
- If you have included any mapped Recordset Elements on your form (either input-mapped, output-mapped or both), by default all columns in the recordset will be included in the PDF template. You can prevent columns from appearing in the template using the Is Visible in PDF property found under the Metadata tab of the Recordset Builder pop-up, which is used to map the Recordset to a Dataset.
- If you are upgrading a Project which contains a Word template (i.e. if the template has been created and saved as described above) and you wish to preserve the template's formatting, you will need to carry out the following steps:
- 1) Browse for and open the older Project within the latest version of Form Studio.
- 2) When the Project has been opened, an Upgrade Project dialog box will appear. Make sure the Backup project before updating option is selected (which it should be, by default). This creates a backup of the Project, saved in the Project location within a folder which contains a _BACKUP suffix.
- 3) Click the Upgrade button.
- 4) When the Upgrade button has been clicked, another dialog box will appear prompting you to Upgrade elements. Click the Upgrade elements button, or click the Do not upgrade button if you decide not to upgrade the Elements. The Project will then open in Form Studio.
- 5) When the Project has opened, click the Project tab in the Project Explorer pane, then expand the Forms folder.
- 6) Right-click on the Form name which contains the Word template with the formatting you wish to retain. This opens a context menu from which Upgrade Word template can be selected.
- 7) Save the template, then open it for editing.
- 8) Once the template has been opened, you will then need to open the backed-up Word template within the WordTemplates folder, located inside the _BACKUP folder.
- 9) Remove the contents of the opened/upgraded Word template, then copy the contents of the backed-up Word template and paste it into the empty opened/upgraded Word template.
- 10) Save the changes to the opened/upgraded Word template. This will retain the formatting from the earlier version.

By default, your PDF files will be called:
<form name>_nnn.pdf
where nnn is the record ID in the submission database table record for the submitted form. The record ID links the PDF file to an individual copy of the form so that users can only access the PDF files they have created.
If you want to use the default name for your PDFs, you don't need to do anything. However, you should make sure you give each form a unique name so that you can identify the PDF files generated by different forms and to ensure that files from one form won't overwrite files from a different form with the same name, if you use the same folder to store PDF files from different forms.
Alternatively you can specify your own file name for your PDFs, if you prefer, and you can even include values entered by a user on the form within the file name to help identify individual PDFs.
When you generate the Word template, as described above under Generate a PDF template, Form Studio will automatically add a function, called getPDFFilename, into the custom JavaScript for the form, which defines the file name to be used for PDFs.
To change the file name, you need to edit the default function to specify your own choice of name. To do this:
Click on the Projects tab in the Project Explorer.
Under the Forms node, find the relevant form and expand that node to see its Script node, if not already visible.
Click on the Scripts node.
The custom JavaScript file will open in an editor.
Scroll down the file to find the getPDFFilename function. The default function will look like this:
function getPDFFilename(recordID)
{
// Hint: You can specify a unique file name for the PDF using values from the various elements used on the form.
// e.g.
// var pdfFileName = form1.page1.ndltextbox1.value;
// Make sure to create unique pdf names. Otherwise, there is a risk of the files getting overwritten.
// If the file name contains invalid characters like '"', '/', '\', ':', '*', '?', '>', '<' or '|', the invalid characters will be replaced with '_' .
// If the file name is longer than the default length(260 characters), the file name will be changed to the default format (formname_recordID).
var pdfFileName = 'Form1_' + recordID;
return pdfFileName;
}
You can now edit the function and replace the default file name, 'Form1_' + recordID, with your own choice of file name. If you want to include data values within the file name, you can reference these in the same way as you would anywhere else in the Script file. For example, you could combine the values input into two of the form fields like this:
When deciding on your file names, you need to ensure that each generated PDF will have a unique file name, to prevent one user viewing a file created by another, if you include a Get PDF Button on your form, and to prevent a file being overwritten by another file with the same file name.
At runtime, if a file name is generated which includes characters that are not allowed within file names, such as '*' or '\', these characters will automatically be replaced with underscore characters, '_'. In this situation, a message will be added to the Server Log to warn you. If the file name generated is invalid, e.g. an empty name, or is greater than 260 characters in length, the default file name, described above, will be used instead.

As well as being able to save a PDF copy of the form to a designated file location (see the Configure a Publishing Profile for PDF file creation, below, for more information), you can also save a PDF to a SQL database. To achieve this, the Save PDF to DB option within the Forms section of the Publishing Profile must be selected. The Create PDF on submit option must also be selected if your form doesn't include a Get PDF Button element. The form must also have a means whereby it can be submitted. This could be achieved using a Submit button, the submitForm function (called from within some custom JavaScript), or the Capita Pay360 payment service, which includes form submission as part of the payment process (see above).
When the form has been configured to contain all of the required components, the Publishing Profile can be accessed and both the Save PDF to DB and Create PDF on submit options can be checked (ticked), if required, as illustrated below.
A dedicated NDLFXPDF database will then be used to store the generated PDFs.
-
As discussed above, if the form contains a Get PDF Button element, you won't need to select the Create PDF on submit option, but this option will need selecting if you want to store a PDF (in either the file system or the SQL database), but don't wish to retrieve and view it at runtime.
Before the Save PDF to DB option has been chosen, a connection string for the NDLFXPDF database won't be visible beneath the Datasources heading within the Publishing Profile. When the option has been selected however, the name of the NDLFXPDF database will be listed alongside other datasources, as shown below.
When the NDLFXPDF connection string information has been added, you will (as with any other datasource) need to enter the required credentials before the Save PDF to DB option can be used - see the Connection section of the Publish your Form topic for details of how to configure a database connection. When the credentials have been entered and the form has been published, a record for the PDF will be added to the NDLFXPDF database. Note that if you de-select the Save PDF to DB option, the connection string for the NDLFXPDF database will still be visible. Before saving your PDF - either to a file location or to a SQL database - you must make sure that a PDF template of the form has been created. See the Generate a PDF template section, above, for more information.
If you include a Get PDF Button element on your form, the Return PDF URL option within the Publishing Profile will automatically be selected and greyed-out to enable the PDF to be retrieved from the database and displayed at runtime when the user clicks or taps the Get PDF Button. If you remove the Get PDF Button element from your form, the Return PDF URL option will remain selected, but will no longer be greyed-out, allowing you to de-select it if required. Note that if the Get PDF Button element is deleted, the Create PDF on submit option will need to be selected.
If you decide to save the form's PDF to a SQL database when the form is first published, the individual PDF records will be placed in the NDLFXPDF database from that point forward. Every time the form is run, a new record will be added. In the below image, a form has been run eight times and eight PDFs have been written to the database.
If you decide that you no longer wish to save the PDFs in the SQL database and would like to write them to the file system instead, the Publishing Profile will have to be opened and you will need to de-select the Save PDF to DB option. Before you re-publish the form, you will need to configure a file path where the PDFs will be saved using the Browse button, , located beneath the PDF Folder column heading. Once you have entered a file path, the form can be re-published, and from that point forward, PDF copies of the form will be written to your chosen file system location. If you decide to switch back to saving PDFs to the SQL database, the Publishing Profile will once again have to be opened and the Save PDF to DB option will need re-selecting.
When retrieving PDFs at runtime using the Get PDF Button, there is no difference between the two archiving options in terms of when or how the PDF will appear, and in what format it will be rendered. In the following example, a simple address capture form has been created and a PDF has been written to the file system and then retrieved at runtime using the Get PDF Button:
In the next image, the same form has been run and a different address has been entered. The Save PDF to DB option has been selected, and the PDF has been retrieved from the SQL database using the Get PDF Button. The PDF has been rendered in the same way for both PDF archiving methods.
In terms of opening a form which has already been set up to save the PDF to the file system, switching to using the SQL database instead won't require any additional re-configuring, other than opening the Publishing Profile and selecting the Save PDF to DB option, as described above. The same applies to a form which has been configured to save PDFs to the SQL database. The Publishing Profile will need to be accessed and the Save PDF to DB option will need de-selecting if you decide to switch to using the file system. No other settings will need amending for either of the two PDF options.
One of the most important considerations when switching a form between the two PDF archiving methods is the fact that you must make sure that you keep a record of when the switch occurred, especially if you are using the enhanced Save As feature to create and develop different versions of the same Digitise Forms project. Knowing which archiving method has been applied to which version will prove invaluable when it comes to deploying and monitoring forms for different users, or for different use cases.
An alternative to toggling the Save PDF to DB option to its selected and de-selected position would be to create two different Publishing Profiles - one for saving the PDF to the file system, and another for saving it to the SQL database. See the Publishing Profiles section of the Publish your Form topic for more information. You would also need to make sure that the correct options were selected within your Publishing Profiles should your form contain a Get PDF Button element, as discussed above.

When you are ready to publish your form, select your Publishing Profile.
To specify that a PDF copy of the form should be automatically created whenever the user submits the form, select the Create PDF on submit option within the Profile's settings.
If you are including PDF file creation in your form, either automatic (using the Create PDF on submit option just mentioned) or allowing a user to manually request a PDF copy (using the Get PDF Button Element), you will need to specify the folder or SQL database to which you want the PDF files to be saved. This is also done within the Publishing Profile, using the PDF Folder or Save PDF to DB options.
-
If you choose to save PDFs to a file location, by default, they will be stored in a subfolder called PDFs, below the form's published web application folder. This folder and its contents will be deleted whenever you republish the form in future. We therefore recommend that you specify a permanent folder, which is valid for the machine hosting your form's Forms Server components and is outside the web application folders.
If you specify a folder outside the web application folders, your PDF files will not be deleted by Digitise Forms, and will remain there. You may, therefore, want to regularly check and, if required, clear out the folder as part of your standard housekeeping procedures.
-
You will need to make sure that the user under which your web app runs has write permissions for the folder you specify. If your web app is running under the ApplicationPoolIdentity user refer to the FAQs for information on giving this user access to your specified folder.
If you want to store your PDFs to a remote network drive rather than on the machine hosting your web app, you should create a service account under which to run your web app, and not use the ApplicationPoolIdentity user, and you must specify the PDF folder as a UNC path, e.g. \\MyPC.myco.com\MyPDFs, using a shared drive and not a mapped drive. You must then give this account change permissions to your chosen folder.

In earlier versions of Digitise Forms, only output-mapped elements were visible within PDFs, along with static items such as titles, labels and images etc. Now, input-mapped values are automatically included in the PDF when the PDF template is generated (described above). The visibility of input-mapped and other items within the PDF is, however, subject to the Is Visible in PDF option being selected for each form element. The Store Request Data item also needs to be selected for configured Datasources within your form's Publishing Profile. For more information, see the Publish Your Form and Map Data to Elements topics.

If you have a droplist or a checklist where the label and value properties of the list are mapped to different dataset fields and the value is output-mapped, the PDF will now automatically show the value of the selected label property, even though the value recorded in the database record is that of the selected value property.
In the following example, using a lookup for personal titles, the droplist and checklist are mapped to a record where the dataset field mapped to the value property is an integer and the dataset field mapped to the label property is a string containing the string value associated with it. The string value is displayed in the PDF:

You can include the Primary Key of the main record created by the form in your PDF by input-mapping it to an element such as the Label element. The Label element allows non-editable text to be displayed on your form, so when the Primary Key is included on your form using this element, you won't be able to amend it.
For more information on working with a form's Primary Key, see the How do I access the last submitted record's unique ID? question in this guide's FAQs section.
Now, if you selected automatic creation of PDF files, whenever the form is submitted a PDF copy of the completed form will be created and saved to your specified folder or SQL database. If you didn't specify automatic creation, a PDF file will be created when a user clicks or taps the Get PDF Button.
You can check whether a PDF template has been created for a form, by examining the form's PDF Mappings and PDF Template properties.